<template>
  <div id="app" class="skLifeTable">
    <a-table
    :columns="columns"
    :data-source="dataSource"
    rowKey="id"
    bordered
  />
  </div>
</template>
<script>
export default {
  name: 'skLifeTable',
  data() {
    return {
      dataSource:[
        {
          grade:"中班",
          class:"中一班",
          weekAverage:23,
          list:[
            {
              dayTime1:1,
              dayTime2:2
            },
            {
              dayTime1:3,
              dayTime2:4
            },
            {
              dayTime1:5,
              dayTime2:6
            },
            {
              dayTime1:7,
              dayTime2:8
            },
            {
              dayTime1:9,
              dayTime2:0
            },
          ]
        },
        {
          grade:"小班",
          class:"小一班",
          weekAverage:23,
          list:[
            {
              dayTime1:1,
              dayTime2:23
            },
            {
              dayTime1:1,
              dayTime2:23
            },
            {
              dayTime1:1,
              dayTime2:23
            },
            {
              dayTime1:1,
              dayTime2:23
            },
            {
              dayTime1:1,
              dayTime2:23
            },
          ]
        },
      ],
      columns:[
        {
          title:'年级',
          align:"center",
          dataIndex: 'grade',
        },
        {
          title:'班级',
          align:"center",
          dataIndex: 'class',
        },
        
        {
          title:'',
          align:"center",
          scopedSlots: { customRender: "stock" },
          children:[
            {
              title:'周平均睡眠时长(分钟)',
              align:"center",
              dataIndex: 'weekAverage',
            }
          ]
        },
      ]
    }
  },
  components: {},

  filters: {},

  computed: {},

  created() {
    // [
    //   {
    //     grade:"中班",
    //     class:"中一班",
    //     weekAverage:23,
    //     day1:"",
    //     day2:"",
    //     day3:"",
    //     day4:"",
    //     day5:""
    //   }
    // ]
    for (let i = 0; i < this.dataSource[0].list.length; i++) {
      this.columns.splice(this.columns.length - 1,0,{
        title:'班级',
        align:"center",
        children:[
          {
            title:'周睡眠时长(分钟)',
            align:"center",
            dataIndex: `list[${i}].dayTime1`,
          },
          {
            title:'周平均睡眠时长(分钟)',
            align:"center",
            dataIndex: `list[${i}].dayTime2`,
          },
        ]
      },)
      
    }
  },

  activated() {},

  mounted() {},

  methods: {}
}
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>
